package com.db.industry.controller;

import com.db.core.vo.PageResult;
import com.db.core.vo.R;
import com.db.industry.dto.IndustryPageDto;
import com.db.industry.entity.Industry;
import com.db.industry.service.IndustryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 作者：Bin
 * 时间：2023/10/29
 * 描述：键盘敲烂，薪资过万
 */
@RestController
@RequestMapping("industry")
@CrossOrigin
public class IndustryController {

    @Autowired(required = false)
    private IndustryService industryService;

    @PostMapping("page")
    public PageResult page(@RequestBody IndustryPageDto industryPageDto){
        return industryService.pageList(industryPageDto);
    }

    @PostMapping("add")
    public R add(@RequestBody Industry industry){
        return industryService.insert(industry);
    }

    @PostMapping("edit")
    public R edit(@RequestBody Industry industry){
        return industryService.update(industry);
    }

    @GetMapping("all")
    public R all(){
        return R.ok(industryService.list(),"success");
    }

}
